﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RealPostage.aspx.cs" Inherits="UI_Bas_RealPostage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>实际邮费维护</title>
    <link href="../../css/admin.css" rel="stylesheet" type="text/css" />
    <script src="../../js/common.js" type="text/javascript"></script>
    <link href="../../js/jquery.easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery.easyui/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery.easyui/jquery.min.js" type="text/javascript"></script>
    <script src="../../js/jquery.easyui/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../js/jquery.easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
  
    <script type ="text/javascript" >
    $(function(){     	
    	var defaultDate = Date.parse('1900/01/01');
        var _$realpostage = $("#realpostage");
        _$realpostage.datagrid({
            border: true,
            width: 1100,
            height: 345,
            title: '邮费列表...',
            remoteSort: false,
            nowrap: true,
            striped: false,
            url: "../../TableHanders.aspx?act=q&tid=49&type=0",
            sortName: 'Id',
            sortOrder: 'asc',
            loadMsg: "正在加载,请稍后...",
            toolbar:[{
                    text:'Add',
                    iconCls:'icon-add',
                    handler:function(){
                         window.location.href="RealPostageDetail.aspx?act=I";
                    }
                   }],
                    
            frozenColumns: [[
                      
                    { title: 'Operation',field: 'opt', width: 80, align: 'center',
                        formatter: function(val, row, index) {
                            var Id = row.Id;                            
                            return  '<a href="#" onclick = "DeleteRow(this);" id = ' + Id + ' rowIndex = ' + index + ' style="color:red;">Delete</a>'
                                + '<a href = "RealPostageDetail.aspx?act=U&id=' + Id + '">  Eidt</a>';
                                    
                        }
                    },
                    { title: 'ck',       field: 'CheckId', checkbox: true },
                    { title: '编号',     field: 'Id', width:50,align:'center', sortable: true},
	                { title: '订单号',   field: 'OrderId', width:180, sortable: true}
				  ]],
            columns: [[
                    { title: '快递公司', field: 'ExpressCompany', width:100, sortable: true, formatter: function(val, rec){
					    if (val ==1) {
					        return 'PPP';
					    }
					    else if (val ==2 ) {
					        return 'romail';
					    }					  
					    else {
					        return val;
					    }
					}
                    },
                    { title: '实际邮费', field: 'RealPostage', width:80, sortable: true},                    
                    { title: '状态',     field: 'Status', width:120, sortable: true, formatter: function(val, rec){
					    if (val ==0) {
					        return '未审核';
					    }
					    else if (val == 1) {
					        return '<span style="color:red;">已审核</span>';
					    }					  
					    else {
					        return val;
					    }
					}
                    },
                    { title: '日期',     field: 'DeliveryDate', width: 150,  sortable: true },
                    { title: '审核人',   field: 'Auser', width: 90,  sortable: true },
                    { title: '备注',   field: 'Mnote', width: 90,  sortable: true }
                                                                           
				]],		   
            pagination: true,
            singleSelect:false,
            pageList: [10, 15, 20]
         });
         //实际邮费审核
       $("#btnshe").click(function(){
            var rows = _$realpostage.datagrid('getSelections');
            if (rows.length == 0) {
                alert('请选择一条邮费记录..');
                return;
            }             
            var yfids = "";
            for (i = 0; i < rows.length; i++) {
                var pId = rows[i].Id;
                yfids += pId + ",";
            }
            yfids = yfids.substring(0, yfids.length - 1);            
            var url =getRootPath() +"/UI/Orders/OrdersHandler.ashx?cmd=sjyfshe&yfids=" + yfids + "&ts=" + new Date().getTime();
            $.getJSON(url, function(data){
                var retData = EvalData(data);
                var code = retData.retCode;
                if (code == 0) {
                    alert('操作成功!');
                    _$realpostage.datagrid('reload');
                }
                else {
                    alert(retData.retMsg);
                }
            });
        });                  
                     
      });   
             
       function DeleteRow(row) {
            var rowAttr = $(row);
            var id = rowAttr.attr('id');
            var rowIndex = rowAttr.attr('rowIndex');
            $.messager.confirm("请确认...", "确认删除?", function(value) {
                if (value) {
                    var url = "../../TableHanders.aspx?act=d&tid=49&type=1&id=" + id;
                    $.getJSON(
                        url,
                        function(data){
                            var sdata = data[0];
                            var code = sdata.code;
                            if (code == 0) {
                                alert(sdata.msg);
                                $("#realpostage").datagrid('deleteRow', rowIndex);
                            }
                            else {
                                alert(sdata.msg);
                            }
                        }
                        );
                }
            });
          }                   
	</script>	
</head>
<body> 
   <div id="body">
       <form id="formQuery" runat="server">
             <div class="div_Title">
                   <span class="Body_Title">》》<%=this.Title %></span>
             </div>  
             <table  id="realpostage"></table>
             <div id ="divOperating"  class="easyui-panel" title="数据操作..." style="margin-bottom:5px; width :1100px;">
             <table >
                   <tr>
                    <td >
                    <a  id ="btnshe"class = "easyui-linkbutton" href ="#" >审核</a>                               
                    </td>
                  </tr>
              </table>
           </div>
       </form>
   </div>
</body>
</html>
